package org.ipp4j.core.standard;

public enum Status {

	/**
	 * Invalid status name
	 */
	INVALID(-1),

	/**
	 * successful-ok
	 */
	OK(0x0000),

	/**
	 * successful-ok-ignored-or-substituted-attributes
	 */
	OK_SUBST(0X0001),

	/**
	 * successful-ok-conflicting-attributes
	 */
	OK_CONFLICT(0X0002),

	/**
	 * successful-ok-ignored-subscriptions
	 */
	OK_IGNORED_SUBSCRIPTIONS(0X0003),

	/**
	 * successful-ok-ignored-notifications
	 */
	OK_IGNORED_NOTIFICATIONS(0x0004),

	/**
	 * successful-ok-too-many-events
	 */
	OK_TOO_MANY_EVENTS(0x0005),

	/**
	 * successful-ok-but-cancel-subscription
	 */
	OK_BUT_CANCEL_SUBSCRIPTION(0x0006),

	/**
	 * successful-ok-events-complete.
	 */
	OK_EVENTS_COMPLETE(0x0007),

	/**
	 * redirection-other-site
	 */
	REDIRECTION_OTHER_SITE(0X0200),

	/**
	 * cup-see-other
	 */
	CUP_SEE_OTHER(0x0280),

	/**
	 * client-error-bad-request
	 */
	BAD_REQUEST(0x0400),

	/**
	 * client-error-forbidden
	 */
	FORBIDDEN(0x0401),

	/**
	 * client-error-not-authenticated
	 */
	NOT_AUTHENTICATED(0x0402),

	/**
	 * client-error-not-authorized
	 */
	NOT_AUTHORIZED(0x0403),

	/**
	 * client-error-not-possible
	 */
	NOT_POSSIBLE(0X0404),

	/**
	 * client-error-timeout
	 */
	TIMEOUT(0X0405),

	/**
	 * client-error-not-found
	 */
	NOT_FOUND(0X0406),

	/**
	 * client-error-gone
	 */
	GONE(0x0407),

	/**
	 * client-error-request-entity-too-large
	 */
	REQUEST_ENTITY(0x0408),

	/**
	 * client-error-request-value-too-long
	 */
	REQUEST_VALUE(0x0409),

	/**
	 * client-error-document-format-not-supported
	 */
	DOCUMENT_FORMAT(0x040A),

	/**
	 * client-error-attributes-or-values-not-supported
	 */
	ATTRIBUTES(0x040B),

	/**
	 * client-error-uri-scheme-not-supported
	 */
	URI_SCHEME(0x040C),

	/**
	 * client-error-charset-not-supported
	 */
	CHARSET(0x040D),

	/**
	 * client-error-confliciting-attributes
	 */
	CONFLICT(0x040E),

	/**
	 * client-error-compression-not-supported
	 */
	COMPRESSION_NOT_SUPPORTED(0X040F),

	/**
	 * client-error-compression-error
	 */
	COMPRESSION_ERROR(0x0410),

	/**
	 * client-error-document-format-error
	 */
	DOCUMENT_FORMAT_ERROR(0x0411),

	/**
	 * client-error-document-access-error
	 */
	DOCUMENT_ACCESS_ERROR(0x0412),

	/**
	 * client-error-attributes-not-settable
	 */
	ATTRIBUTES_NOT_SETTABLE(0x0413),

	/**
	 * client-error-ignored-all-subscriptions
	 */
	IGNORED_ALL_NOTIFICATIONS(0x0414),

	/**
	 * client-error-too-many-subscriptions
	 */
	TOO_MANY_SUBSCRIPTIONS(0X0415),

	/**
	 * client-error-ignored-all-notifications
	 */
	IGNORED_ALL_SUBSCRIPTIONS(0x0416),

	/**
	 * client-error-print-support-file-not-found
	 */
	PRINT_SUPPORT_FILE_NOT_FOUND(0x0417),

	/**
	 * client-error-document-password-error
	 */
	DOCUMENT_PASSWORD_ERROR(0x0418),

	/**
	 * client-error-document-permission-error
	 */
	DOCUMENT_PERMISSION_ERROR(0x0419),

	/**
	 * client-error-document-security-error
	 */
	DOCUMENT_SECURITY_ERROR(0x0420),

	/**
	 * client-error-document-unprintable-error
	 */
	DOCUMENT_UNPRINTABLE_ERROR(0x0421),

	/**
	 * server-error-internal-error
	 */
	INTERNAL_ERROR(0x0500),

	/**
	 * server-error-operation-not-supported
	 */
	OPERATION_NOT_SUPPORTED(0x0501),

	/**
	 * server-error-service-unavailable
	 */
	SERVICE_UNAVAILABLE(0x0502),

	/**
	 * server-error-version-not-supported
	 */
	VERSION_NOT_SUPPORTED(0x0503),

	/**
	 * server-error-device-error
	 */
	DEVICE_ERROR(0x0504),

	/**
	 * server-error-temporary-error
	 */
	TEMPORARY_ERROR(0x505),

	/**
	 * server-error-not-accepting
	 */
	NOT_ACCEPTING(0x506),

	/**
	 * server-error-busy
	 */
	PRINTER_BUSY(0x0507),

	/**
	 * server-error-job-canceled
	 */
	ERROR_JOB_CANCELED(0x0508),

	/**
	 * server-error-multiple-document-jobs-not-supported
	 */
	MULTIPLE_JOBS_NOT_SUPPORTED(0x0509),

	/**
	 * server-error-printer-is-deactivated
	 */
	PRINTER_IS_DEACTIVATED(0x50A),

	/**
	 * server-error-too-many-jobs
	 */
	TOO_MANY_JOBS(0x050B),

	/**
	 * server-error-too-many-documents
	 */
	TOO_MANY_DOCUMENTS(0x050C),

	/**
	 * Authentication canceled by user
	 */
	AUTHENTICATION_CANCELED(0x1000),

	/**
	 * Error negotiating a secure connection
	 */
	PKI_ERROR(0x1001),

	/**
	 * TLS upgrade required
	 */
	UPGRADE_REQUIRED(0x1002);

	int code;
	byte[] bytes;

	Status(int code) {
		this.code = code;
		this.bytes = new byte[] { (byte) (this.code >>> 8), (byte) (this.code) };
	}

	public static Status valueOf(short code) {
		for (Status status : Status.values()) {
			if (status.code == code) {
				return status;
			}
		}
		throw new IllegalArgumentException("Status code " + code
				+ " cannot be found.");
	}

	public byte[] toByteArray() {
		return bytes;
	}
}
